#ifndef SLIPANDPSD_H
#define SLIPANDPSD_H

#include <QWidget>
#include <QTimer>


namespace Hydra_SlipAndPSD {
typedef enum _state
{
    INIT,                                   // 初始态
    SLIP_SLIDE,                             // 空转打滑
    PSD_NOT_CLOSED                          // 站台门未关闭
}STATE;
}

using namespace Hydra_SlipAndPSD;

class SlipAndPSD : public QWidget
{
    Q_OBJECT

public:
    SlipAndPSD(QWidget *parent = 0);
    void setInterval(quint16 interval);
    void setState(STATE state);
    STATE getState();

public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void initParam();
    void drawImage(QPainter *pPainter);
    void drawSlipSlide(QPainter *pPainter);
    void drawPSD(QPainter *pPainter);


private:
    QTimer mTimer;                                                                                  // 计时器
    QPoint mCenterPoint;                                                                            // 控件中心
    quint8 mImageHeightProportion = 80;                                                             // 图形高度占控件高度百分比
    quint8 mImageWidthProportion = 60;                                                              // 图形宽度占控件宽度百分比
    quint16 mSpacing = 20;                                                                          // 间隙
    QColor mSlipColor = QColor(189, 0, 0);                                                          // 空转/打滑颜色
    QColor mPSDColor = QColor(255, 254, 0);                                                         // 站台门颜色
    quint8 mInsideOutsideProportion = 65;                                                           // 站台门内外矩形长度或宽度百分比
    STATE mState = STATE::INIT;                                                                     // 状态
    quint8 mWheelCircleLineWidth = 5;                                                               // 车轮圆形线条宽度
    QRect mWheelRect;                                                                               // 车轮圆形外接矩形
    QPoint mLeftTriangleTop;                                                                        // 左侧三角顶角
    QPoint mLeftTriangleBottomLeft;                                                                 // 左侧三角左边底角
    QPoint mLeftTriangleBottomRight;                                                                // 左侧三角右边底角
    QPoint mRightTriangleTop;                                                                       // 左侧三角顶角
    QPoint mRightTriangleBottomLeft;                                                                // 右侧三角左边底角
    QPoint mRightTriangleBottomRight;                                                               // 右侧三角右边底角
    QRect mLeftOutsideRect;                                                                         // 左侧车门外侧矩形
    QRect mLeftInsideRect;                                                                          // 左侧车门内侧矩形
    QRect mRightOutsideRect;                                                                        // 右侧车门外侧矩形
    QRect mRightInsideRect;                                                                         // 右侧车门内侧矩形
    quint16 mOutsideDoorLineWidth = 6;                                                              // 车门外侧矩形线条宽度
};

#endif // SLIPANDPSD_H
